import java.util.Comparator;

public class PokerComparator implements Comparator<Poker> {
    private static final String[] COLOR_ORDER = {"黑桃", "红桃", "梅花", "方块"};
    private static final String[] POINT_ORDER = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};

    @Override
    public int compare(Poker p1, Poker p2) {
        // 比较花色
        int colorIndex1 = getColorIndex(p1.getColor());
        int colorIndex2 = getColorIndex(p2.getColor());
        if (colorIndex1 != colorIndex2) {
            return colorIndex1 - colorIndex2;
        }

        // 花色相同，比较点数（从大到小）
        int pointIndex1 = getPointIndex(p1.getPoint());
        int pointIndex2 = getPointIndex(p2.getPoint());
        return pointIndex2 - pointIndex1;
    }

    private int getColorIndex(String color) {
        for (int i = 0; i < COLOR_ORDER.length; i++) {
            if (COLOR_ORDER[i].equals(color)) {
                return i;
            }
        }
        return -1;
    }

    private int getPointIndex(String point) {
        for (int i = 0; i < POINT_ORDER.length; i++) {
            if (POINT_ORDER[i].equals(point)) {
                return i;
            }
        }
        return -1;
    }
}    